<?php
// user控制器
// 
class UserController extends Controller
{
	public $model = null;
	public function __construct(){
	parent::__construct();
	$this->model = new Model('user');
}
	public function index(){
		
		$data = $this->model->order('id desc')->select();
		// var_dump($model->select());
		$this->assign('title','用户列表');
		$this->assign('list',$data);
		$this->display('User/index.html');

	
	}

	public function del(){
		if($this->model->delete($_GET['id'])){
		   $this->redirect('恭喜你,删除成功!','./index.php?c=user');
		} else {
			$this->redirect('删除失败!','./index.php?c=user');
		}
	}


	public function edit(){
		$data = $this->model->find($_GET['id']);
		$this->assign('title','编辑用户');
		$this->assign('data',$data);
		$this->display('User/edit.html');
	}

	public function update(){
		if($this->model->update()){
			$this->redirect('恭喜你,编辑成功!','./index.php?c=user');
		
	} else {
            $this->redirect('恭喜你,编辑失败!');
        }

}
	public function add(){
		$this->assign('title', '填个用户!');
         $this->display('User/add.html');
	}


	public function insert(){
		if ($this->model->insert() > 0) {
            $this->redirect('恭喜你,新增成功!', './index.php?c=user');
        } else {
            $this->redirect('恭喜你,新增失败!');
        }
	}
}



























